package com.sk.bilibili.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.sk.bilibili.bean.Goods;
import com.sk.bilibili.other.R;
import com.sk.bilibili.service.GoodsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author 邵康
 * @date 2021/12/09 23:27
 */
@Api(tags = "商品信息 暂放数据")
@CrossOrigin
@RestController
@RequestMapping("/goods")
public class GoodsController {

    @Autowired
    private GoodsService goodsService;

    @ApiOperation("add")
    @PostMapping("/add")
    public R<Void> add(Goods goods) {
        return goodsService.add(goods);
    }

    @ApiOperation("delete")
    @GetMapping("/delete")
    public R<Void> delete(Integer id) {
        return goodsService.delete(id);
    }

    @ApiOperation("update")
    @PostMapping("/update")
    public R<Void> update(Goods goods) {
        return goodsService.update(goods);
    }

    @ApiOperation("page")
    @GetMapping("/page")
    public R<IPage<Goods>> page(@RequestParam(defaultValue = "1") Integer page,
                                @RequestParam(defaultValue = "10") Integer size,
                                Boolean magic) {
        return goodsService.page(page, size,magic);
    }

}
